4 #define NUMBER_OF_INPUTS 33
5 #define LCLICK inputArray.at(LEFTMOUSECLICKED) && !inputArray.at(LEFTMOUSEHELD)
6 #define LHELD inputArray.at(LEFTMOUSEHELD)
7 #define RCLICK inputArray.at(RIGHTMOUSECLICKED) && !inputArray.at(RIGHTMOUSEHELD)
8 #define RHELD inputArray.at(RIGHTMOUSEHELD)
12 inputArray
.reserve(NUMBER_OF_INPUTS
);
13 for (int i
= 0; i
< NUMBER_OF_INPUTS
; i
++) {
14 inputArray
.push_back(false);
27 //Returns a pointer to the origional array
28 std::vector
<bool>* MouseIO::processMouseInput(int * x
, int * y
) {
29 //std::cout << inputArray[MOUSECLICKED];
30 if (inputArray
[MOUSECLICKED
] == true) inputArray
[MOUSEHELD
] = true;
31 else inputArray
[MOUSEHELD
] = false;
32 if (inputArray
[LEFTMOUSECLICKED
] == true) inputArray
[LEFTMOUSEHELD
] = true;
33 else inputArray
[LEFTMOUSEHELD
] = false;
34 if (inputArray
[RIGHTMOUSECLICKED
] == true) inputArray
[RIGHTMOUSEHELD
] = true;
35 else inputArray
[RIGHTMOUSEHELD
] = false;
36 //if (inputArray[MIDDLEMOUSECLICKED] == true) inputArray[MIDDLEMOUSEHELD] = true;
38 inputArray
[MIDDLEMOUSEHELD
] = false; inputArray
[MIDDLEMOUSECLICKED
] = false;
39 if (inputArray
[MOUSEWHEELUP
] == true) inputArray
[MOUSEWHEELUP
] = false;
40 if (inputArray
[MOUSEWHEELDOWN
] == true) inputArray
[MOUSEWHEELDOWN
] = false;
41 while (SDL_PollEvent(&evnt
)) {
44 inputArray
[QUIT
] = true;
47 SDL_GetMouseState(x
, y
);
50 if (evnt
.wheel
.y
> 0) {
51 inputArray
[MOUSEWHEELUP
] = true;
53 else if(evnt
.wheel
.y
< 0) {
54 inputArray
[MOUSEWHEELDOWN
] = true;
56 case SDL_MOUSEBUTTONDOWN
:
57 inputArray
[MOUSECLICKED
] = true;
58 if (evnt
.button
.button
== SDL_BUTTON_LEFT
)
59 inputArray
[LEFTMOUSECLICKED
] = true;
60 if (evnt
.button
.button
== SDL_BUTTON_RIGHT
)
61 inputArray
[RIGHTMOUSECLICKED
] = true;
62 if(evnt
.button
.button
= SDL_BUTTON_MIDDLE
)
63 inputArray
[MIDDLEMOUSECLICKED
] = true;
65 case SDL_MOUSEBUTTONUP
:
66 if (evnt
.button
.button
== SDL_BUTTON_RIGHT
)
67 inputArray
[RIGHTMOUSECLICKED
] = false;
68 if (evnt
.button
.button
== SDL_BUTTON_LEFT
)
69 inputArray
[LEFTMOUSECLICKED
] = false;
70 if(!(inputArray
[RIGHTMOUSECLICKED
] || inputArray
[LEFTMOUSECLICKED
]))
71 inputArray
[MOUSECLICKED
] = false;
72 if (!(evnt
.button
.button
= SDL_BUTTON_MIDDLE
))
73 inputArray
[MIDDLEMOUSECLICKED
] = false;
80 void MouseIO::trackDestopMouse(int* x
, int* y
) {
81 SDL_GetGlobalMouseState(x
, y
);
84 void MouseIO::trackGameMouse(int* x
, int* y
) {
85 SDL_GetMouseState(x
, y
);
88 int MouseIO::calculateMouseDistance(int x
, int y
) {
92 (oldX
- x
) * (oldX
- x
) + (oldY
- y
) * (oldY
- y
)
94 distanceCounter
+= distance
;
103 void MouseIO::resetDistanceCounter() {
104 distanceCounter
= 0; oldX
= -1; oldY
= -1;
108 //0 is exit pressed, 1 is held, 2 is clicked
109 //Returns a copy of the origional array
110 std::vector
<bool> MouseIO::getInputArray() {